#!/usr/bin/env python
# -*-coding:UTF-8-*-
# Author: chenzuoqing@126.com
# Create: 2018/7/24 16:43
# File  : filter.py

"""

"""

import django_filters
from cabinet.models import Cabinet


class CabinetFilter(django_filters.FilterSet):
    """
    name对应关联的field，这里的lookup_expr表达式代表是模糊查询，可以使用其他表达式
    method传入一个自定义过滤函数，传入值返回函数过滤的内容
    """
    name = django_filters.CharFilter(name='name', lookup_expr='icontains')
    idc = django_filters.CharFilter(name='idc', lookup_expr='exact')

    class Meta:
        model = Cabinet
        fields = ['name', 'idc']
